home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / N-P / NIFTY / myCShell / AppleEvents.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-17  |  2.9 KB  |  157 lines  |  [TEXT/KAHL]

  1. /*********************************************************
  2.  "AppleEvents.c"
  3.  
  4.  by John A. Love, III [ Washington Apple Pi Users' Group]
  5.  
  6.  using Symantec's "THINK C", v 5.00
  7.  *********************************************************/
  8.  
  9.  
  10. #ifndef __APPLEEVENTS__
  11. #include <AppleEvents.h>
  12. #endif
  13.  
  14. #ifndef __EPPC__
  15. #include <EPPC.h>
  16. #endif
  17.  
  18. #ifndef __GESTALTEQU__
  19. #include <GestaltEqu.h>
  20. #endif
  21.  
  22. #include "protos"
  23.  
  24. #include "globals.h"
  25. #include "extern.h"
  26.  
  27.  
  28.  
  29.  
  30.     short    _GestaltTrap = 0xA1AD;
  31.     long    myFeature;
  32.  
  33.  
  34. Boolean AppleEventsActive (void)    {
  35. /* Do we have a machine on which the Apple Events Manager exists ??? */
  36.  
  37.     if (TrapAvailable(_GestaltTrap))    {
  38.         if (Gestalt(gestaltAppleEventsAttr, &myFeature) == noErr)    {
  39.             if (BitTst(&myFeature, 31 - gestaltAppleEventsPresent))    return(true);
  40.             else return(false);
  41.         }
  42.         else return(false);
  43.     }
  44.     else return(false);
  45.  
  46. }    /* AppleEventsActive */
  47.  
  48.  
  49.  
  50. Boolean PPCToolboxActive (void)    {
  51. /* Do we have a machine on which the PPCToolbox exists ??? */
  52.  
  53.         Boolean    result;
  54.  
  55.  
  56.     result = false;            /* Be pessimistic ... see if I care !! */
  57.     ;
  58.     if (TrapAvailable(_GestaltTrap))    {
  59.         if (Gestalt(gestaltPPCToolboxAttr, &myFeature) == noErr)    {
  60.             if (BitTst(&myFeature, 31 - gestaltPPCToolboxPresent))    result = true;
  61.         }
  62.     }
  63.  
  64.     return(result);
  65.  
  66. }    /* PPCToolboxActive */
  67.  
  68.  
  69.  
  70. OSErr InitAppleEvents (void)    {
  71.  
  72.  
  73.  
  74. }    /* InitAppleEvents */
  75.  
  76.  
  77.  
  78. OSErr InitPPCToolbox (void)    {
  79.  
  80.         OSErr    err;
  81.  
  82.  
  83.     gHasPPCToolbox = PPCToolboxActive();
  84.  
  85.     if (gHasPPCToolbox)    {
  86.  
  87.         if ((myFeature & gestaltPPCSupportsRealTime) == 0)    {
  88.             err = PPCInit();
  89.             if (err == noErr)    err = Gestalt(gestaltPPCToolboxAttr, &myFeature);
  90.         }
  91.         else    /* does NOT need initialization */    err = noErr;
  92.     }
  93.     else    err = noPPCToolboxErr;
  94.  
  95.     return (err);
  96.  
  97. }    /* InitPPCToolbox */
  98.  
  99.  
  100.  
  101. OSErr    AcceptHLEvent (void)    {
  102.  
  103.         OSErr            err;
  104.         Ptr                myBuff;
  105.         unsigned long    myLen;
  106.         TargetID        theClient;
  107.         unsigned long    clientRefcon;
  108.  
  109.  
  110.     myLen = 0;          /* Start with zero to allow _AcceptHighLevelEvent */
  111.     myBuff = nil;       /*  to determine the size.                        */
  112.  
  113.     err = AcceptHighLevelEvent(&theClient, &clientRefcon, myBuff, &myLen);
  114.     ;
  115.     if (err == bufferIsSmall)    {
  116.         myBuff = NewClearPtr(myLen);
  117.         err = AcceptHighLevelEvent(&theClient, &clientRefcon, myBuff, &myLen);
  118.     }
  119.  
  120.     return (err);
  121.  
  122. }    /* AcceptHLEvent */
  123.  
  124.  
  125.  
  126. OSErr    MissedAnyParameters (EventRecord *event, AppleEvent *theAEEvent)    {
  127.  
  128.         OSErr        err;
  129.         DescType    ignoredActualType;
  130.         AEKeyword    missedKeyword;
  131.         Size        ignoredActualSize;
  132.  
  133.  
  134.     err = AEGetAttributePtr(theAEEvent,
  135.                             keyMissedKeywordAttr,
  136.                             typeKeyword,
  137.                             &ignoredActualType,
  138.                             (Ptr)(&missedKeyword),
  139.                             sizeof(missedKeyword),
  140.                             &ignoredActualSize);
  141.  
  142.     if (err == noErr)    {        /* We found some unused parameters. */
  143.         event->message = *(long *) (&ignoredActualType);
  144.         event->where = *(Point *) (&missedKeyword);
  145.         err = errAEEventNotHandled;
  146.     }
  147.     else if (err == errAEDescNotFound)    err = noErr;    /* No more. */
  148.  
  149.     return (err);
  150.  
  151. }    /* MissedAnyParameters */
  152.  
  153.  
  154.  
  155.  
  156. /*  { end file "AppleEvents.c" }  */
  157.